!pip install plotly
Requirement already satisfied: plotly in c:\users\emmanuel\anaconda3 new\lib\site-packages (4.14.3) Requirement already satisfied: six in c:\users\emmanuel\anaconda3 new\lib\site-packages (from plotly) (1.15.0) Requirement already satisfied: retrying>=1.3.3 in c:\users\emmanuel\anaconda3 new\lib\site-packages (from plotly) (1.3.3)
import pandas as pd
import numpy as np
LFP2018 = pd.read_csv(r'C:\Users\Emmanuel\Desktop\LFP2018.CSV')
LFP2018.head()
| State | Labour Force Population | Total Employed | Total Unemployed Plus Underemployed | |
|---|---|---|---|---|
| 0 | ABIA | 2023767.765 | 1384053.764 | 9.719402e+05 |
| 1 | ADAMAWA | 1588278.284 | 1257232.151 | 7.246126e+05 |
| 2 | AKWA-IBOM | 3599981.393 | 2242227.699 | 2.081274e+06 |
| 3 | ANAMBRA | 3251914.782 | 2683681.973 | 1.140385e+06 |
| 4 | BAUCHI | 2122724.499 | 1624123.445 | 1.000323e+06 |
LFP2018rates = pd.read_csv(r'C:\Users\Emmanuel\Desktop\LFP2018rates.CSV')
LFP2018rates.head()
| State | OLD Nigeria | NEW Nigeria | International | Underemployment rate | State_No | |
|---|---|---|---|---|---|---|
| 0 | ABIA | 48.026273 | 31.610050 | 9.782458 | 16.416223 | 32 |
| 1 | ADAMAWA | 45.622522 | 20.843081 | 7.616070 | 24.779441 | 3 |
| 2 | AKWA-IBOM | 57.813479 | 37.715575 | 18.132588 | 20.097904 | 7 |
| 3 | ANAMBRA | 35.068116 | 17.473791 | 8.515652 | 17.594324 | 11 |
| 4 | BAUCHI | 47.124472 | 23.488731 | 12.282571 | 23.635740 | 8 |
import plotly.io as pio
import plotly.express as px
import plotly.graph_objs as go
fig=px.bar(LFP2018rates , y = 'Underemployment rate', x= 'State', orientation = 'v' , text = 'Underemployment rate')
fig.update_traces(texttemplate='%{text:.6s}%' , textposition='inside')
fig.update_layout(uniformtext_minsize= 8, uniformtext_mode='hide')
fig.update_layout(
title = {
'text':"Labour Force Population 2018",
'y':0.9,
'x':0.5,
'xanchor':'center',
'yanchor':'bottom'},height = 1000, width =1000)
fig=px.bar(LFP2018rates, y = 'OLD Nigeria ', x= 'State', orientation = 'v' ,text = 'OLD Nigeria ')
fig.update_traces(texttemplate='%{text:.4s}%' , textposition='inside')
fig.update_layout(uniformtext_minsize=12, uniformtext_mode='hide')
fig.update_layout(
title = {
'text':'Underemployment rate OLD Nigeria',
'y':0.95,
'x':0.5,
'xanchor':'center',
'yanchor':'bottom'},height = 800, width = 650)
import json
import plotly.express as px
with open (r"C:\Users\Emmanuel\Desktop\NBS_states.geojson") as f:
geo_data = json.load(f)
geo_data["features"][7]["id"]
'Bauchi'
nig_cords = {"lat": 9.0820, "lon":8.6753}
state_id_map={}
for feature in geo_data['features']:
feature['id']=feature['properties']['OBJECTID']
state_id_map[feature['properties']['OBJECTID']]= feature['id']
nig_cords = {"lat": 9.0820, "lon":8.6753}
geo_data['features'][23]['id']
24
fig = px.choropleth_mapbox(
LFP2018rates,
geojson= geo_data,
locations= "State_No",
color = "Underemployment rate",
center = nig_cords,
hover_name="State",
zoom = 5,
opacity = 0.95,
color_continuous_scale="agsunset",
mapbox_style="carto-positron",
labels = {"STATES":"Underemployment rate" and "Total Employed"}
)
fig.update_layout(margin={"t":0,"b":0,"l":0,"r":0})
fig.show()